import Vue from 'vue'
import Router from 'vue-router'
import Layout from '@/layout'

Vue.use(Router)

export const constantRoutes = [
  {
    path: '/login',
    component: () => import('@/views/login/index'),
    hidden: true
  },
  {
    path: '/',
    component: Layout,
    redirect: '/dashboard',
    children: [{
      path: 'dashboard',
      name: 'Dashboard',
      component: () => import('@/views/dashboard/index'),
      meta: { title: '工作台', icon: 'el-icon-s-home' }
    }]
  },
  // {
  //   path: '/party-member',
  //   component: Layout,
  //   name: 'PartyMember',
  //   meta: { title: '学生管理', icon: 'el-icon-user' },
  //   children: [
  //     {
  //       path: 'list',
  //       name: 'PartyMemberList',
  //       component: () => import('@/views/party-member/list'),
  //       meta: { title: '学生列表' }
  //     }
  //   ]
  // },
  {
    path: '/class-overview',
    component: Layout,
    name: 'classOverview',
    meta: { title: '班级学习情况', icon: 'el-icon-user' },
    children: [
      {
        path: 'list',
        name: 'classOverviewList',
        component: () => import('@/views/class-overview/list'),
        meta: { title: '班级学习情况' }
      }
    ]
  },
  {
    path: '/learning-process',
    component: Layout,
    name: 'learningProcess',
    meta: { title: '学习过程', icon: 'el-icon-user' },
    children: [
      {
        path: 'learning-process',
        name: 'learningProcess',
        component: () => import('@/views/learning-process/index'),
        meta: { title: '学习过程' }
      }
    ]
  },
  {
    path: '/interaction-analysis',
    component: Layout,
    name: 'interactionAnalysis',
    meta: { title: '课堂互动数据分析', icon: 'el-icon-user' },
    children: [
      {
        path: 'interaction-analysis',
        name: 'interactionAnalysis',
        component: () => import('@/views/interaction-analysis/index'),
        meta: { title: '课堂互动数据分析' }
      }
    ]
  },
  {
    path: '/preview-analysis',
    component: Layout,
    name: 'previewAnalysis',
    meta: { title: '预习数据分析', icon: 'el-icon-user' },
    children: [
      {
        path: 'preview-analysis',
        name: 'previewAnalysis',
        component: () => import('@/views/preview-analysis/index'),
        meta: { title: '预习数据分析' }
      }
    ]
  },
  {
    path: '/homework-analysis',
    component: Layout,
    children: [
      {
        path: 'index',
        name: 'HomeworkAnalysis',
        component: () => import('@/views/homework-analysis/index'),
        meta: { title: '作业数据分析', icon: 'el-icon-s-data' }
      }
    ]
  },
  {
    path: '/cluster-analysis',
    component: Layout,
    children: [
      {
        path: 'index',
        name: 'ClusterAnalysis',
        component: () => import('@/views/cluster-analysis/index'),
        meta: { title: '聚类分析', icon: 'el-icon-s-data' }
      }
    ]
  },
  {
    path: '/study',
    component: Layout,
    name: 'Study',
    meta: { title: '学习资源', icon: 'el-icon-reading' },
    children: [
      {
        path: 'resource',
        name: 'StudyResource',
        component: () => import('@/views/study/resource'),
        meta: { title: '资源库' }
      },
      {
        path: 'course',
        name: 'StudyCourse',
        component: () => import('@/views/study/course'),
        meta: { title: '在线课程' }
      },
      {
        path: 'record',
        name: 'StudyRecord',
        component: () => import('@/views/study/record'),
        meta: { title: '学习记录' }
      }
    ]
  },
  {
    path: '/system',
    component: Layout,
    name: 'System',
    meta: { title: '系统管理', icon: 'el-icon-setting' },
    children: [
      {
        path: 'user',
        name: 'SystemUser',
        component: () => import('@/views/system/user'),
        meta: { title: '用户管理' }
      },
      {
        path: 'role',
        name: 'SystemRole',
        component: () => import('@/views/system/role'),
        meta: { title: '角色管理' }
      },
      {
        path: 'menu',
        name: 'SystemMenu',
        component: () => import('@/views/system/menu'),
        meta: { title: '菜单管理' }
      },
      {
        path: 'log',
        name: 'SystemLog',
        component: () => import('@/views/system/log'),
        meta: { title: '操作日志' }
      }
    ]
  }
]

export const asyncRoutes = []

const createRouter = () => new Router({
  mode: 'history',
  scrollBehavior: () => ({ y: 0 }),
  routes: constantRoutes
})

const router = createRouter()

export function resetRouter() {
  const newRouter = createRouter()
  router.matcher = newRouter.matcher
}

export default router
